package com.tm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tm.dto.OrderQueryDto;
import com.tm.entity.OrderEntity;
import com.tm.mapper.OrderMapper;
import com.tm.service.OrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @PROJECT_NAME: tm-wm-syb
 * @DESCRIPTION:
 * @USER: DELL
 * @DATE: 2023/4/10 8:26
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderEntity> implements OrderService {
    @Resource
    private OrderMapper orderMapper;

    @Override
    public Page<OrderEntity> query(OrderQueryDto orderQueryDto) {
        QueryWrapper<OrderEntity> wrapper = new QueryWrapper<>();
        OrderEntity orderEntity = new OrderEntity();
        wrapper.eq(orderQueryDto.getNumber() != null,"number",orderQueryDto.getNumber());
        wrapper.ge(orderQueryDto.getBeginTime() != null,"order_time",orderQueryDto.getBeginTime());
        wrapper.le(orderQueryDto.getEndTime() != null,"order_time",orderQueryDto.getEndTime());
        Page<OrderEntity> page = new Page<>(orderQueryDto.getPage(),orderQueryDto.getPageSize());
        Page<OrderEntity> page1 = orderMapper.selectPage(page, wrapper);
        return page1;
    }
}
